Make clipmasks work for pixbuf rendering
authorAlexander Larsson <alexl@redhat.com>
Tue, 7 Jul 2009 12:51:38 +0000 (14:51 +0200)
committerAlexander Larsson <alexl@redhat.com>
Tue, 7 Jul 2009 15:10:49 +0000 (17:10 +0200)
This is more important in the client side windows world, as clip masks
may be used for clipping to non-native subwindows. This fixes a bug
in aisleriot where it uses masked pixbuf drawing and it ends up drawing
over the moving card subwindow.

NEWS
gdk/gdkdraw.c
gdk/x11/gdkdrawable-x11.c

diff --git a/NEWS b/NEWS
index 29b3fa6c614a8a7da3c057c4d25a5e8c252af059..06fae6705edeba53649064cd29a3d9a72c0dbf79 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,12 @@
+Overview of Changes from GTK+ 2.17.3 to 2.17.4
+==============================================
+
+* Support for clipmasks in gdk_draw_pixbuf now works, this will
+  introduce visual changes in code that uses clipmasks when drawing
+  pixbufs. However, since this never worked that is unlikely to happen.
+  Old code using gdk_pixbuf_render_threshold_alpha masks when rendering
+  pixbufs will now produce truncated results at the edges.
+
 Overview of Changes from GTK+ 2.17.2 to 2.17.3
 ==============================================
 
index 869d535888be5ecfc4788ed15367d570ab6077c7..44652bcbe8f85552517ff872f91d984102d01936 100644 (file)
@@ -752,9 +752,6 @@ gdk_draw_image (GdkDrawable *drawable,
  * On older X servers, rendering pixbufs with an alpha channel involves round 
  * trips to the X server, and may be somewhat slow.
  *
- * The clip mask of @gc is ignored, but clip rectangles and clip regions work
- * fine.
- *
  * If GDK is built with the Sun mediaLib library, the gdk_draw_pixbuf
  * function is accelerated using mediaLib, which provides hardware
  * acceleration on Intel, AMD, and Sparc chipsets.  If desired, mediaLib
index 537a47e0fb5d4da445d8eeb807746a5d23adefc5..b2cac294c33d8d3d74ac25d5174bb7720d1e6431 100644 (file)
@@ -388,9 +388,22 @@ gdk_x11_drawable_update_picture_clip (GdkDrawable *drawable,
   else
     {
       XRenderPictureAttributes pa;
-      pa.clip_mask = None;
+      GdkBitmap *mask;
+      gulong pa_mask;
+
+      pa_mask = CPClipMask;
+      if (gc && (mask = _gdk_gc_get_clip_mask (gc)))
+       {
+         pa.clip_mask = GDK_PIXMAP_XID (mask);
+         pa.clip_x_origin = gc->clip_x_origin;
+         pa.clip_y_origin = gc->clip_y_origin;
+         pa_mask |= CPClipXOrigin | CPClipYOrigin;
+       }
+      else
+       pa.clip_mask = None;
+
       XRenderChangePicture (xdisplay, picture,
-                           CPClipMask, &pa);
+                           pa_mask, &pa);
     }
 }